#include <iostream>

#include "linked_list.h"

using namespace std;

LinkedList::LinkedList() : head(NULL) {}

LinkedList::~LinkedList()
{
   Node *to_delete;
	Node *p = head;
	while (p)
   {
      to_delete = p;
		p = p->next;
      delete to_delete;
	}
}

void LinkedList::insert(int value)
{
	Node *p = new Node(value, head);
	head = p;
}

ostream &operator <<(ostream &os, const LinkedList &linkedList) {
	Node *p = linkedList.head;
	while (p) {
		os << p->data << " ";
		p = p->next;
	}
	return os;
}